﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.UI.WebControls.WebParts;
using CreditAgricole.Application;
using System.Web.UI.WebControls;
using CreditAgricole.Framework;
using Microsoft.SharePoint;

namespace CreditAgricole.PageCodeBehind
{
    public class BKnowledgeViewsWebpart: BaseViewsWebPart
    {

        /// <summary>
        /// Add the views menu
        /// </summary>
        protected override void AddViewsMenu()
        {
            base.AddViewsMenu();
            ViewsMenu.AddNewMenuItem("Mes articles");
            ViewsMenu.AddNewMenuItem("Documents à réviser");
            ViewsMenu.AddNewMenuItem("Articles en release");
        }

        /// <summary>
        /// Get data to bind with gridview and call method BindToGridView
        /// </summary>
        protected override void GetDataBindToGridview()
        {
            base.GetDataBindToGridview();
            switch (ViewsMenu.SelectedMenu)
            {
                case Constants.ElementsMenu.MenuItem1:
                    {
                        SelectedItems = DataKnowledgeBase.GetMyKBase(SiteId, WebId, Constants.KnowledgeApprovedListTitle, SPContext.Current.Web.CurrentUser.ID);
                        break;
                    }
                case Constants.ElementsMenu.MenuItem2:
                    {
                        SelectedItems = DataKnowledgeBase.GetKBaseObj(SiteId, WebId, Constants.KnowledgeUnapprovedListTitle);
                        break;
                    }
                case Constants.ElementsMenu.MenuItem3:
                    {
                        SelectedItems = DataKnowledgeBase.GetKBaseObj(SiteId, WebId, Constants.KnowledgeApprovedListTitle);
                        break;
                    }
                default:
                    {
                        SelectedItems = DataKnowledgeBase.GetMyKBase(SiteId, WebId, Constants.KnowledgeApprovedListTitle, SPContext.Current.Web.CurrentUser.ID);
                        break;
                    }
            }
            if (SelectedItems.Count > 0)
            {
                BindToGridView();
            }
        }
    }
}
